import { ref, onMounted, onBeforeUnmount } from 'vue'

export default function() {
  const x = ref(-1)
  const y = ref(-1)

  const mousePositin = (e: MouseEvent) => {
    x.value = e.pageX
    y.value = e.pageY
  }

  onMounted(() => {
    document.addEventListener('click', mousePositin)
  })
  onBeforeUnmount(() => {
    document.removeEventListener('click', mousePositin)
  })

  return {
    x,
    y
  }
}
